package avicit.bdp.dgs.mdm.rest;

import avicit.bdp.dgs.mdm.service.MdmMetricService;
import avicit.platform6.core.rest.msg.ResponseMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2023-12-11
 * @类说明：DataManageRest
 * @修改记录：
 * @注意事项：
 * @主要功能：数据维护Rest接口
 */
@RestController
@Api(tags = "mdm", description = "数据维护Rest接口")
@RequestMapping("/api/bdp/dgs/mdm/data")
public class MdmMetricRest {
    @Autowired
    private MdmMetricService metricService;

    /**
     * 查看基本指标，包括主题总量、数据总量、已分发数据总量
     *
     * @return
     */
    @GetMapping("/basicMetrics")
    @ApiOperation(value = "查看基本指标")
    public ResponseMsg<Map<String, Object>> queryBasicMetrics() {
        ResponseMsg<Map<String, Object>> responseMsg = new ResponseMsg<>();

        responseMsg.setResponseBody(this.metricService.queryBasicMetrics());

        return responseMsg;
    }

    /**
     * 根据状态统计数据总量
     *
     * @return
     */
    @GetMapping("/distribution")
    @ApiOperation(value = "根据状态统计数据总量")
    public ResponseMsg<List<Map<String, Object>>> queryDataDistribution() {
        ResponseMsg<List<Map<String, Object>>> responseMsg = new ResponseMsg<>();

        responseMsg.setResponseBody(this.metricService.queryDataDistribution());

        return responseMsg;
    }

    /**
     * 查看24h/7d/30d新增数据趋势图
     *
     * @param timeMode 时间，0：近24h、1：近7天、2：近30天、3：本月
     * @return
     */
    @GetMapping("/trend")
    @ApiOperation(value = "查看24h/7d/30d新增数据趋势图")
    public ResponseMsg<List<Map<String, Object>>> queryDataTrend(@ApiParam(value = "timeMode", name = "timeMode") Integer timeMode) {
        ResponseMsg<List<Map<String, Object>>> responseMsg = new ResponseMsg<>();

        responseMsg.setResponseBody(this.metricService.queryDataTrend(timeMode));

        return responseMsg;
    }
}
